import React from 'react'
import PropTypes from 'prop-types'
import { Table, Avatar } from 'antd'
import config from 'config'
import AnimTableBody from 'components/DataTable/AnimTableBody'
import '../../../utils/index'

const timestampToTime = (timestamp) => {
  let dateObj = new Date(timestamp)
  return dateObj.format('yyyy-qq-dd HH:mm:ss')
}

const List = ({ location, isMotion, ...tableProps }) => {

  const columns = [
    {
      title: '部门',
      dataIndex: 'dept.name',
      key: 'dept.name'
    },
    {
      title: "下单金额合计",
      dataIndex: 'totalAmount',
      key: 'totalAmount'
    },
    {
      title: "下单个数",
      dataIndex: 'totalNum',
      key: 'totalNum'
    },
    {
      title: "签收金额",
      dataIndex: 'signAmount',
      key: 'signAmount'
    },
    {
      title: "签收个数",
      dataIndex: 'signTotalNum',
      key: 'signTotalNum'
    },
    {
      title: "在途金额",
      dataIndex: 'wayAmount',
      key: 'wayAmount'
    },
    {
      title: "在途个数",
      dataIndex: 'wayTotalNum',
      key: 'wayTotalNum'
    },
    {
      title: "退回金额",
      dataIndex: 'sendAmount',
      key: 'sendAmount'
    },
    {
      title: "退回个数",
      dataIndex: 'sendTotalNum',
      key: 'sendTotalNum'
    },
  ]

  const AnimateBody = (props) => {
    return <AnimTableBody {...props} />
  }

  const CommonBody = (props) => {
    return <tbody {...props} />
  }

  return (
    <Table
      {...tableProps}
      columns={columns}
      scroll={{ x: 1400 }}
      simple
      rowKey={record => record.id}
      components={{
        body: { wrapper: isMotion ? AnimateBody : CommonBody },
      }}
    />
  )
}

List.propTypes = {
  location: PropTypes.object
}

export default List
